<?php
class DkpEvents extends Zend_Db_Table_Abstract {
	protected $_name = 'dkp_events';
	protected $_dependentTables = array('RaidJoins','RaidLeaves','RaidAdjustments','RaidDrops','RaidKills');
	
	public static $NO_DKP = 0;
	public static $SIGNUP_BONUS = 1;
	public static $CONFIRM_BONUS = 2;
	public static $UNSIGN = 3;
	public static $NOT_PREPARED = 4;
	public static $LEAVING_EARLY = 5;
	public static $LATE = 6;
	public static $NO_SHOW = 7;
	public static $FARM_KILL = 8;
	public static $PROGRESS_KILL = 9;
	public static $FIRST_TIME_KILL = 10;
	public static $LOOT = 11;
	
	/**
	 * Short hand for getting a raid by its id.
	 * 
	 * This function does mysql safe escaping on the raid id.
	 *
	 * @param 	int 			raid id
	 * @return 	TableRow|null
	 */
	public static function getById($dkpEventId)
	{	
		// Raid id must be numeric
		if (!is_numeric($dkpEventId)) {
			return null;
		}
		
		// Create static self
		$table = new self();
		
		// Create a select for getting the raid
		$select = $table->select()->where("id = ?", $dkpEventId);
		$dkpEvent = $table->fetchRow($select);
		
		// Return the raid or null
		if ($dkpEvent) {
			return $dkpEvent;
		} else {
			return null;
		}
	}
}
?>